/**
 * 引用dll
 */
const path = require('path');
const wp = require('webpack');
const hp = require('happypack');

module.exports = {
    entry: {
        idx: path.resolve(__dirname, 'src/idx.js')
    },
    output: {
        path: path.resolve(__dirname, 'dist/'),
        filename: '[name].[chunkHash].js'
    },
    module: {
        rules: [
            {
                test: /\.css$/,
                use:[{
                    loader: 'happypack/loader?id=a', // id 做关联happypack
                }]
            }
        ]
    },
    plugins: [
        new wp.DllReferencePlugin({
            manifest: path.resolve(__dirname, 'src/dll/vendor.manifest.json') //代表我们的map的地址
        }),
        // 多个map，就多个插件的实例new。

        new wp.optimize.UglifyJsPlugin({
            parallel: true, // 开启并行
            cache: true // 开启缓存
        }),


        // happypack
        new hp({
            id: 'a', // 给module里面loader用的key css相关的实际配置放到了这里来搞。
            loaders: [{
                loader: 'style-loader'
            },{
                loader: 'css-loader'
            }] // 进程实际处理的loader
        }),
    ] 
}
